listbox: Rewrite coords from child windows
authorAlexander Larsson <alexl@redhat.com>
Mon, 17 Jun 2013 12:52:05 +0000 (14:52 +0200)
committerAlexander Larsson <alexl@redhat.com>
Mon, 17 Jun 2013 13:15:07 +0000 (15:15 +0200)
If button events are from child windows we need to rewrite
the coordinates to our window.

gtk/gtklistbox.c

index f335a1a1d906d782571c2a2290995f2da5068b06..20b2fe90428a9ac9a364d3f560dc4f1ba61f1610 100644 (file)
@@ -1197,6 +1197,8 @@ gtk_list_box_real_button_press_event (GtkWidget      *widget,
   GtkListBox *list_box = GTK_LIST_BOX (widget);
   GtkListBoxPrivate *priv = list_box->priv;
   gboolean ctrl_pressed;
+  GdkWindow *window;
+  double x, y;
 
   if (event->button == GDK_BUTTON_PRIMARY)
     {
@@ -1206,7 +1208,17 @@ gtk_list_box_real_button_press_event (GtkWidget      *widget,
 
       priv->active_row = NULL;
 
-      row = gtk_list_box_get_row_at_y (list_box, event->y);
+      window = event->window;
+      x = event->x;
+      y = event->y;
+
+      while (window && window != gtk_widget_get_window (widget))
+        {
+          gdk_window_coords_to_parent (window, x, y, &x, &y);
+          window = gdk_window_get_effective_parent (window);
+        }
+
+      row = gtk_list_box_get_row_at_y (list_box, y);
       if (row != NULL)
         {
           if (ctrl_pressed)